<template>
	<view class="index" :style="{'height':windowHeight}">
		<clothes></clothes>
		<view class="binding">
			<view class="binding-li" v-for="(item,index) in list" :key="index">
				<view class="li-txt">{{item.name}}</view>
				<view class="li-icon" @click="ChangClick(item,index)" v-if="item.type == 0">
					<image src="/static/qq2.png" mode=""></image>
				</view>
				<view class="li-icon" v-if="item.type == 1">
					<image src="/static/qq1.png" mode=""></image>
				</view>
			</view>
			
		</view>
	</view>
</template>
<script>
	export default {
		components: {},
		data() {
			return {
				windowHeight: "200px", 
				wifiName:'',
				wifiPwd:'',
				list:[
					{
						id:1,
						name:'关机',
						type:1,
					},{
						id:2,
						name:'重启',
						type:0,
					},{
						id:3,
						name:'出厂设置',
						type:0,
					}
				]
			}
		},
		onLoad() {
			this.GaoDu() //判断手机高度
		},
		onShow() {
			
		},
		methods: {
			ChangClick(item,index){
				for (let i = 0; i < this.list.length; i++) {
					this.list[i].type = 0
				}
				this.list[index].type = 1
				const value = uni.getStorageSync('iponeInfo');
				this.$REQ(this.$api.jhSendCmd, {
					sn: value.deviceNo,
					cmdId:item.id
				}, 'POST').then(res => {
					console.log(res)
					uni.showToast({
						duration: 1000,
						title:res.data.msg,
						icon: 'none',
					})
				}).catch(err => {
					console.log(err)
					uni.showToast({
						duration: 1000,
						title:err.data.msg,
						icon: 'none',
					})
				})
			},
			// 判断手机高度
			GaoDu() {
				console.log('12356')
				// 判断手机页面的高度
				uni.getSystemInfo({

					success: (res) => {
						this.windowHeight = res.windowHeight + "px";
					}
				})
			},
		}
	}
</script>

<style scoped lang="less">
	.binding-li{
		display: flex;
		flex-wrap: nowrap;
		justify-content:space-between;
		border-bottom: 1rpx solid #eee;
		background: #fff;
		padding: 25rpx;
		margin-bottom: 20rpx;
		border-radius: 10rpx;
	}
	.binding{
		padding: 25rpx;
	}
	.li-txt{
		font-size: 28rpx;
		line-height: 35rpx;
	}
	.li-icon{
		width: 35rpx;
		height: 35rpx;
	}
	image{
		width: 100%;
		height: 100%;
	}

</style>